<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 16] JDK Tools</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:04:01 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch15_03.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 16</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch16_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="JNUT2-CH-16">16. JDK Tools</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
appletviewer<br>
<A HREF="ch16_02.htm">jar</A><BR>
<A HREF="ch16_03.htm">java</A><BR>
<A HREF="ch16_04.htm">javac</A><BR>
<A HREF="ch16_05.htm">javadoc</A><BR>
<A HREF="ch16_06.htm">javah</A><BR>
<A HREF="ch16_07.htm">javakey</A><BR>
<A HREF="ch16_08.htm">javap</A><BR>
<A HREF="ch16_09.htm">jdb</A><BR>
<A HREF="ch16_10.htm">native2ascii</A><BR>
<A HREF="ch16_11.htm">serialver</A><BR>

<p>
</DIV>

<A NAME="CH16.APPLETVIEWER1"></A><A NAME="CH16.JDK.JAVA.DE1"></A><A NAME="CH16.JDK.JAVA.DE1X"></A><A NAME="CH16.APPLETS-VIEW1"></A>

<DIV CLASS=refnamediv>
<H1>appletviewer</H1>

<H2>Name</H2>

appletviewer---The Java Applet Viewer

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.1">Availability</A></h2>

<P CLASS=para>
JDK 1.0 and later.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.2">Synopsis</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
appletviewer [-debug]  [-J<I CLASS=emphasis>javaoption</I>] [-encoding <I CLASS=emphasis>enc</I>] <I CLASS=emphasis>url|file</I>...
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.3">Description</A></h2>

<P CLASS=para>
<I CLASS=emphasis>appletviewer</I> reads or downloads one or more HTML documents
specified by filename or URL on the command line.  It reads
or downloads all
the applets referenced in each document and displays them,
each in their own window.  If none of the named documents
has an <tt CLASS=literal>&lt;APPLET&gt;</tt> tag, <I CLASS=emphasis>appletviewer</I> does
nothing.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.4">Options</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>-debug</tt><br>
<DD>

<P CLASS=para>
If this option is specified, the <I CLASS=emphasis>appletviewer</I> is
started within <I CLASS=emphasis>jdb</I> (the Java debugger).  This allows
you to debug the applets referenced by the document or
documents.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>-J</tt><I CLASS=emphasis><tt CLASS=literal>javaoption</tt></I><br>
<DD>

<P CLASS=para>
This option passes the following <I CLASS=emphasis><tt CLASS=literal>javaoption</tt></I> as a
command-line argument to the Java interpreter.  The
specified <I CLASS=emphasis><tt CLASS=literal>javaoption</tt></I> should not contain spaces.  If
a multi-word option must be passed to the Java interpreter,
multiple <tt CLASS=literal>-J</tt> options should be used.  See <I CLASS=emphasis>java</I>
for a list of valid Java interpreter options.  Available in
JDK 1.1 and later.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>-encoding</tt><I CLASS=emphasis><tt CLASS=literal>enc</tt></I><br>
<DD>

<P CLASS=para>
This option specifies the character encoding that
<I CLASS=emphasis>appletviewer</I> should use when reading the contents of
the specified files or URLs.  It is used in the
conversion of applet parameter values to Unicode.
Available in JDK 1.1 and later.</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.5">Commands</A></h2>

<P CLASS=para>
The window displayed by <I CLASS=emphasis>appletviewer</I> contains a single
<b>Applet</b> menu, with the following commands available:

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><b>Restart</b><br>
<DD>

<P CLASS=para>
Stops and destroys the current applet, then re-initializes
and restarts it.

<p>
<DT CLASS=varlistentry><b>Reload</b><br>
<DD>

<P CLASS=para>
Stops, destroys, and unloads the applet, then reloads,
reinitializes, and restarts it.

<p>
<DT CLASS=varlistentry><b>Stop</b><br>
<DD>

<P CLASS=para>
Stops the current applet.  Available in Java 1.1 and later.

<p>
<DT CLASS=varlistentry><b>Save</b><br>
<DD>

<P CLASS=para>
Serializes the applet and saves the serialized applet in the
file <I CLASS=emphasis>Applet.ser</I> in the user's home directory.  The
applet should be stopped before selecting this option.
Available in Java 1.1 and later.

<p>
<DT CLASS=varlistentry><b>Start</b><br>
<DD>

<P CLASS=para>
Restarts a stopped applet.
Available in Java 1.1 and later.

<p>
<DT CLASS=varlistentry><b>Clone</b><br>
<DD>

<P CLASS=para>
Creates a new copy of the applet in a new <I CLASS=emphasis>appletviewer</I> window.

<p>
<DT CLASS=varlistentry><b>Tag</b><br>
<DD>

<P CLASS=para>
Pops up a dialog box that displays the <tt CLASS=literal>&lt;APPLET&gt;</tt> tag
and all associated <tt CLASS=literal>&lt;PARAM&gt;</tt> tags that created the
current applet.

<p>
<DT CLASS=varlistentry><b>Info</b><br>
<DD>

<P CLASS=para>
Pops up a dialog box that contains information about the
applet.  This information is provided by the
<tt CLASS=literal>getAppletInfo()</tt> and <tt CLASS=literal>getParameterInfo()</tt>
methods implemented by the applet.

<p>
<DT CLASS=varlistentry><b>Edit</b><br>
<DD>

<P CLASS=para>
This command is not implemented.  The <b>Edit</b> menu item
is disabled.

<p>
<DT CLASS=varlistentry><b>Character Encoding</b><br>
<DD>

<P CLASS=para>
Displays the current character encoding in the status line.
Available in Java 1.1 and later.

<p>
<DT CLASS=varlistentry><b>Print</b><br>
<DD>

<P CLASS=para>
Prints the applet.  Available in Java 1.1 and later.

<p>
<DT CLASS=varlistentry><b>Properties</b><br>
<DD>

<P CLASS=para>
Displays a dialog that allows the user to set <I CLASS=emphasis>appletviewer</I>
preferences, including settings for firewall and caching
proxy servers.

<p>
<DT CLASS=varlistentry><b>Close</b><br>
<DD>

<P CLASS=para>
Closes the current <I CLASS=emphasis>appletviewer</I> window.

<p>
<DT CLASS=varlistentry><b>Quit</b><br>
<DD>

<P CLASS=para>
Quits <I CLASS=emphasis>appletviewer</I>, closing all open windows.</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.6">Properties</A></h2>

<P CLASS=para>
When it starts up, <I CLASS=emphasis>appletviewer</I> reads property
definitions from the file <I CLASS=emphasis>~/.hotjava/properties</I> (UNIX)
or the <I CLASS=emphasis>.hotjava\properties</I> file relative to the
<tt CLASS=literal>HOME</tt> environment variable (Windows).  These
properties are stored in the system properties list and are
used to specify the various error and status messages the
applet viewer displays, as well as its security policies and
use of proxy servers.  The properties that affect security
and proxies are described below.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.7">Security</A></h2>

<P CLASS=para>
The following properties specify the security restrictions
that <I CLASS=emphasis>appletviewer</I> places on untrusted applets:

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>acl.read</tt><br>
<DD>

<P CLASS=para>
This is a list of files and directories that an untrusted applet is
allowed to read.  The elements of the list should be
separated with colons on UNIX systems and semicolons on
Windows systems.  On UNIX systems, the <tt CLASS=literal>~</tt> character
is replaced with the home directory of the current user.  If
the plus character appears as an element in the list,
it is replaced by the value of the
<tt CLASS=literal>acl.read.default</tt> property.  This provides an easy
way to enable read access--by simply setting
<tt CLASS=literal>acl.read</tt> to "+".  By default, untrusted applets are
not allowed to read any files or directories.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>acl.read.default</tt><br>
<DD>

<P CLASS=para>
This is a list of files and directories that are readable by
untrusted applets if the <tt CLASS=literal>acl.read</tt> property contains
a plus character.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>acl.write</tt><br>
<DD>

<P CLASS=para>
This is a list of files and directories that an untrusted applet is
allowed to write to.  The elements of the list should be
separated with colons on UNIX systems and semicolons on
Windows systems.  On UNIX systems, the <tt CLASS=literal>~</tt> character
is replaced with the home directory of the current user.  If
the plus character appears as an element in the list,
it is replaced by the value of the
<tt CLASS=literal>acl.write.default</tt> property.  This provides an easy
way to enable write access--by simply setting
<tt CLASS=literal>acl.write</tt> to "+".  By default, untrusted applets are
not allowed to write to any files or directories.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>acl.write.default</tt><br>
<DD>

<P CLASS=para>
This is a list of files and directories that are writable by
untrusted applets if the <tt CLASS=literal>acl.write</tt> property contains
a plus character.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>appletviewer.security.mode</tt><br>
<DD>

<P CLASS=para>
This property specifies the types of network access an
untrusted applet is allowed to perform.  If it is set to
"none", then the applet can perform no networking at all.
The value "host" is the default, and specifies that the
applet can connect only to the host from which it was
loaded. The value "unrestricted" specifies that an applet
may connect to any host without restrictions.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>package.restrict.access.package-prefix</tt><br>
<DD>

<P CLASS=para>
Properties of this form may be set to <tt CLASS=literal>true</tt> to prevent
untrusted applets from using classes in any package that
has the specified package name prefix as the first component
of its name.  For example, to prevent applets from using any
of the Sun classes (such as the Java compiler and the
appletviewer itself) that are shipped with the JDK, you
could specify the following property:

<DIV CLASS=screen>
<P>
<PRE>
package.restrict.access.sun=true
</PRE>
</DIV>

<P CLASS=para>
<I CLASS=emphasis>appletviewer</I> sets this property to <tt CLASS=literal>true</tt> by
default for the <tt CLASS=literal>sun.*</tt> and <tt CLASS=literal>netscape.*</tt>
packages.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>package.restrict.definition.package-prefix</tt><br>
<DD>

<P CLASS=para>
Properties of this form may be set to <tt CLASS=literal>true</tt> to prevent
untrusted applets from defining classes in a package that
has the specified package name prefix as the first component
of its name.  For example, to prevent an applet from
defining classes in any of the standard Java packages, you
could specify the following property:

<DIV CLASS=screen>
<P>
<PRE>
package.restrict.definition.java=true
</PRE>
</DIV>

<P CLASS=para>
<I CLASS=emphasis>appletviewer</I> sets this property to <tt CLASS=literal>true</tt> by
default for the <tt CLASS=literal>java.*</tt>, <tt CLASS=literal>sun.*</tt>, and
<tt CLASS=literal>netscape.*</tt> packages.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>property.applet</tt><br>
<DD>

<P CLASS=para>
When a property of this form is set to <tt CLASS=literal>true</tt> in Java
1.1, it specifies that an applet should be allowed to read
the property named <tt CLASS=literal>property</tt> from the system
properties list.  By default, applets are only allowed to
read ten standard system properties (see <A HREF="ch14_01.htm">Chapter 14, <i>System Properties</i></A>, for a list).  For example, to allow
an applet to read the <tt CLASS=literal>user.home</tt> property, specify a
property of the form

<DIV CLASS=screen>
<P>
<PRE>
user.home.applet=true
</PRE>
</DIV>

</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.8">Proxies</A></h2>

<P CLASS=para>
<I CLASS=emphasis>appletviewer</I> uses the following properties to
configure its use of firewall and caching proxy servers:

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>firewallHost</tt><br>
<DD>

<P CLASS=para>
This is the firewall proxy host to connect to if the
<tt CLASS=literal>firewallSet</tt> property is <tt CLASS=literal>true</tt>.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>firewallPort</tt><br>
<DD>

<P CLASS=para>
This is the port of the firewall proxy host to connect to if the
<tt CLASS=literal>firewallSet</tt> property is <tt CLASS=literal>true</tt>.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>firewallSet</tt><br>
<DD>

<P CLASS=para>
This tells you whether the applet viewer should use a firewall proxy.
Values are <tt CLASS=literal>true</tt> or <tt CLASS=literal>false</tt>.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>proxyHost</tt><br>
<DD>

<P CLASS=para>
This is the caching proxy host to connect to if the <tt CLASS=literal>proxySet</tt>
property is <tt CLASS=literal>true</tt>.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>proxyPort</tt><br>
<DD>

<P CLASS=para>
This is the port of the caching proxy host to connect to if the
<tt CLASS=literal>proxySet</tt> property is <tt CLASS=literal>true</tt>.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>proxySet</tt><br>
<DD>

<P CLASS=para>
This tells you whether the applet viewer should use a caching proxy.
Values are <tt CLASS=literal>true</tt> or <tt CLASS=literal>false</tt>.</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.9">Environment</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>CLASSPATH</tt><br>
<DD>

<P CLASS=para>
Specifies an ordered list (colon-separated on UNIX,
semicolon-separated on Windows systems) of directories and
ZIP files in which <I CLASS=emphasis>appletviewer</I> should look for class
definitions.  When a path is specified with this environment
variable, <I CLASS=emphasis>appletviewer</I> always implicitly appends the
location of the system classes to the end of the path.  If
this environment variable is not specified, the default path
is the current directory and the system classes.  Note that
<I CLASS=emphasis>appletviewer</I> does not support the <tt CLASS=literal>-classpath</tt>
command-line argument, except indirectly through the
<tt CLASS=literal>-J</tt> option.</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JNUT2-CH-16-SECT-1.10">See Also</A></h2>

<P CLASS=para>
<I CLASS=emphasis>java</I>, <I CLASS=emphasis>javac</I>, <I CLASS=emphasis>jdb</I>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch16_11.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch16_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>serialver</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>jar</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
